# -*- coding: utf-8 -*-
# @Time    : 2022/7/29 20:56
# @Author  : ttkl
# @Email   : ai346627669@qq.com
# @File    : register.py.py
# @Software: PyCharm
import unittest
import requests
import ddt
from config.setting import DATA_PATH

@ddt.ddt
class TestRegister(unittest.TestCase):
    @ddt.file_data(DATA_PATH)
    def test_register(self, **case_data):
        """合法注册"""
        url = "http://hn216.api.yesapi.cn/api/App/User/Register"
        data = case_data.get('data')    #获取请求参数
        expected = case_data.get('expected')    #获取断言参数
        print(data)
        result = requests.post(url=url, json=data)
        rest = result.text
        rest = rest.replace('":"', '=').replace('":', '=')

        for ex in expected:
            print(expected)
            self.assertIn(str(ex), rest)    #结果断言
